package com.muyu.danmo.controller;


import com.muyu.common.core.domain.Result;
import com.muyu.common.core.utils.poi.ExcelUtil;
import com.muyu.common.core.web.controller.BaseController;
import com.muyu.common.log.annotation.Log;
import com.muyu.common.log.enums.BusinessType;
import com.muyu.common.security.annotation.RequiresPermissions;
import com.muyu.danmo.domain.DanmoCollectType;
import com.muyu.danmo.service.IDanmoCollectTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 拾贝类型Controller
 *
 * @author yangle
 * @date 2024-10-30
 */
@RestController
@RequestMapping("/collectType")
public class DanmoCollectTypeController extends BaseController
{
    @Autowired
    private IDanmoCollectTypeService danmoCollectTypeService;

    /**
     * 查询拾贝类型列表
     */
//    @RequiresPermissions("system:collectType:list")
    @GetMapping("/list")
    public Result list(DanmoCollectType danmoCollectType)
    {
        startPage();
        List<DanmoCollectType> list = danmoCollectTypeService.selectDanmoCollectTypeList(danmoCollectType);
        return getDataTable(list);
    }

    /**
     * 导出拾贝类型列表
     */
//    @RequiresPermissions("system:collectType:export")
    @Log(title = "拾贝类型", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DanmoCollectType danmoCollectType)
    {
        List<DanmoCollectType> list = danmoCollectTypeService.selectDanmoCollectTypeList(danmoCollectType);
        ExcelUtil<DanmoCollectType> util = new ExcelUtil<DanmoCollectType>(DanmoCollectType.class);
        util.exportExcel(response, list, "拾贝类型数据");
    }

    /**
     * 获取拾贝类型详细信息
     */
//    @RequiresPermissions("system:collectType:query")
    @GetMapping(value = "/{id}")
    public Result getInfo(@PathVariable("id") Long id)
    {
        return success(danmoCollectTypeService.selectDanmoCollectTypeById(id));
    }

    /**
     * 新增拾贝类型
     */
//    @RequiresPermissions("system:collectType:add")
    @Log(title = "拾贝类型", businessType = BusinessType.INSERT)
    @PostMapping
    public Result add(@RequestBody DanmoCollectType danmoCollectType)
    {
        return toAjax(danmoCollectTypeService.insertDanmoCollectType(danmoCollectType));
    }

    /**
     * 修改拾贝类型
     */
//    @RequiresPermissions("system:collectType:edit")
    @Log(title = "拾贝类型", businessType = BusinessType.UPDATE)
    @PutMapping
    public Result edit(@RequestBody DanmoCollectType danmoCollectType)
    {
        return toAjax(danmoCollectTypeService.updateDanmoCollectType(danmoCollectType));
    }

    /**
     * 删除拾贝类型
     */
//    @RequiresPermissions("system:collectType:remove")
    @Log(title = "拾贝类型", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public Result remove(@PathVariable Long[] ids)
    {
        return toAjax(danmoCollectTypeService.deleteDanmoCollectTypeByIds(ids));
    }
}
